package cn.bdqn.asecu.service;

import cn.bdqn.pojo.Type;
import cn.bdqn.repository.Asecu_ProjectTypeRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * 项目类型也业务层
 * @author 8
 */
@Service
public class AsecuProjectTypeService {
    @Resource
    Asecu_ProjectTypeRepository asecu_projectTypeRepository;

    /**
     * 获取数据
     * @return
     */
    public List<Type> getData() {
        List<Type> typeList = asecu_projectTypeRepository.findAll();
        return typeList;
    }

    /**
     * 添加
     * @param t
     * @return
     */
    @Transactional
    public boolean save(Type t) {
        Type save = asecu_projectTypeRepository.save(t);
        if (null!=save){
            return true;
        }
        return false;
    }

    /**
     * 删除项目类型
     * @param ids
     */
    public void delProjectType(Integer[] ids) {
        for (Integer id : ids) asecu_projectTypeRepository.deleteById(id);
    }
}
